﻿package com.sz.login.servlet;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.sz.login.bmo.ILoginBMO;
import com.sz.manager.dao.IManagerDAO;

public class LogoutServlet extends HttpServlet {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected final Log logger = LogFactory.getLog(getClass());
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		doPost(request, response);
	}
	
	@SuppressWarnings("unchecked")
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		try {
				logger.info("注销当前用户");
				request.getSession().removeAttribute("userid");
				request.getSession().removeAttribute("username");
				request.getSession().removeAttribute("regionid");
				request.getSession().removeAttribute("regionname");
				request.getSession().removeAttribute("usertype");
				request.getSession().removeAttribute("modules");
				
				//跳转页面
				String path = request.getContextPath(); //形如：/otprj
				response.sendRedirect(path + "/index.jsp");		

		} catch (Exception e) {
			logger.error(e.getMessage());
			throw new ServletException(e.getMessage());
		}

	}


}
